package com.dynamixsoftware.printershare.smb;

import com.dynamixsoftware.printershare.smb.ntlmssp.Type1Message;
import com.dynamixsoftware.printershare.smb.ntlmssp.Type2Message;
import com.dynamixsoftware.printershare.smb.ntlmssp.Type3Message;
import com.dynamixsoftware.printershare.smb.util.Dumper;

class NtlmContext
{
  private NtlmPasswordAuthentication auth;
  private boolean isEstablished = false;
  private String netbiosName = null;
  private int ntlmsspFlags;
  private byte[] serverChallenge = null;
  private byte[] signingKey = null;
  private int state = 1;
  private String workstation;
  
  NtlmContext(NtlmPasswordAuthentication paramNtlmPasswordAuthentication, boolean paramBoolean)
  {
    this.auth = paramNtlmPasswordAuthentication;
    this.ntlmsspFlags = (0x20000000 | 0x80000 | 0x4 | this.ntlmsspFlags);
    if (paramBoolean) {
      this.ntlmsspFlags = (0x40008010 | this.ntlmsspFlags);
    }
    this.workstation = Type1Message.getDefaultWorkstation();
  }
  
  public String getNetbiosName()
  {
    return this.netbiosName;
  }
  
  public byte[] getServerChallenge()
  {
    return this.serverChallenge;
  }
  
  public byte[] getSigningKey()
  {
    return this.signingKey;
  }
  
  byte[] initSecContext(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws SmbException
  {
    switch (this.state)
    {
    default: 
      throw new SmbException("Invalid state");
    case 1: 
      byte[] arrayOfByte2 = new Type1Message(this.ntlmsspFlags, this.auth.getDomain(), this.workstation).toByteArray();
      this.state = (1 + this.state);
      return arrayOfByte2;
    }
    try
    {
      Type2Message localType2Message = new Type2Message(paramArrayOfByte);
      this.serverChallenge = localType2Message.getChallenge();
      this.ntlmsspFlags &= localType2Message.getFlags();
      Type3Message localType3Message = new Type3Message(localType2Message, this.auth.getPassword(), this.auth.getDomain(), this.auth.getUsername(), this.workstation, this.ntlmsspFlags);
      byte[] arrayOfByte1 = localType3Message.toByteArray();
      if ((0x10 & this.ntlmsspFlags) != 0) {
        this.signingKey = localType3Message.getMasterKey();
      }
      this.isEstablished = true;
      this.state = (1 + this.state);
      return arrayOfByte1;
    }
    catch (Exception localException)
    {
      throw new SmbException(localException.getMessage(), localException);
    }
  }
  
  public boolean isEstablished()
  {
    return this.isEstablished;
  }
  
  public String toString()
  {
    String str1 = "NtlmContext[auth=" + this.auth + ",ntlmsspFlags=0x" + Dumper.toHexString(this.ntlmsspFlags, 8) + ",workstation=" + this.workstation + ",isEstablished=" + this.isEstablished + ",state=" + this.state + ",serverChallenge=";
    String str2;
    String str3;
    if (this.serverChallenge == null)
    {
      str2 = str1 + "null";
      str3 = str2 + ",signingKey=";
      if (this.signingKey != null) {
        break label213;
      }
    }
    label213:
    for (String str4 = str3 + "null";; str4 = str3 + Dumper.toHexString(this.signingKey, 0, 2 * this.signingKey.length))
    {
      return str4 + "]";
      str2 = str1 + Dumper.toHexString(this.serverChallenge, 0, 2 * this.serverChallenge.length);
      break;
    }
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.smb.NtlmContext
 * JD-Core Version:    0.7.0.1
 */